package com.neu.af.dataFilter.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neu.af.dataFilter.entity.MonitorStatus;
import com.neu.af.dataFilter.mapper.MonitorStatusMapper;
import com.neu.af.dataFilter.service.MonitorStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("monitorStatusService")
public class MonitorStatusServiceImpl implements MonitorStatusService {
    @Autowired
    MonitorStatusMapper monitorStatusMapper;

    @Override
    public int insert(MonitorStatus monitorStatus) {
        return 0;
    }

    @Override
    public int update(MonitorStatus monitorStatus) {
        return monitorStatusMapper.update(monitorStatus);
    }

    @Override
    public int delete(String id) {
        return monitorStatusMapper.delete(id);
    }

    @Override
    public MonitorStatus getById(String id) {
        return monitorStatusMapper.getById(id);
    }

    @Override
    public List<MonitorStatus> getAll() {
        return monitorStatusMapper.getAll();
    }

    @Override
    public List<MonitorStatus> getAllByFilter(Map<String, Object> map) {
        return monitorStatusMapper.getAllByFilter(map);
    }

    @Override
    public List<MonitorStatus> getAllAbnormal() {
        return monitorStatusMapper.getAllAbnormal();
    }

    @Override
    public PageInfo<MonitorStatus> getAllAbnormal(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize,true);
        List<MonitorStatus> monitorStatuses = monitorStatusMapper.getAllAbnormal();
        return new PageInfo<>(monitorStatuses);
    }

    @Override
    public int updateByTagNameWithAbStatus(Map<String, Object> map) {
        return monitorStatusMapper.updateByTagNameWithAbStatus(map);
    }

    @Override
    public int updateAllNormalStatus() {
        return monitorStatusMapper.updateAllNormalStatus();
    }

    @Override
    public List<MonitorStatus> getAbnormalMonitorByFilter(Map<String, Object> map) {
        return monitorStatusMapper.getAllByFilter(map);
    }

    @Override
    public PageInfo<MonitorStatus> getAllByFilter(Integer pageNum, Integer pageSize) {
        return this.getAllByFilter(pageNum, pageSize, new HashMap());
    }

    @Override
    public PageInfo<MonitorStatus> getAllByFilter(Integer pageNum, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum,pageSize,true);
        List<MonitorStatus> monitorStatuses = monitorStatusMapper.getAllByFilter(map);
        return new PageInfo<>(monitorStatuses);
    }

    @Override
    public int updateByTagNameWithDatasourceInterupt(Map<String, Object> map) {
        return monitorStatusMapper.updateByTagNameWithDatasourceInterupt(map);
    }

    @Override
    public List<MonitorStatus> getDataSourceInterupt() {
        return monitorStatusMapper.getDataSourceInterupt();
    }

    @Override
    public List<MonitorStatus> getDataSourceInterupt2(Map<String,Object> map) {
        return monitorStatusMapper.getDataSourceInterupt2(map);
    }

    @Override
    public PageInfo<MonitorStatus> getAllByFilter2(Integer pageNum, Integer pageSize, Map<String, Object> map) {
        PageHelper.startPage(pageNum,pageSize,true);
        List<MonitorStatus> monitorStatuses = monitorStatusMapper.getDataSourceInterupt2(map);
        return new PageInfo<>(monitorStatuses);
    }

    @Override
    public int searchStatus5() {
        return monitorStatusMapper.searchStatus5().size();
    }
}
